<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title>禁用词汇</title>
</head>
<body>
<script>
    var myString = 'Mmm, I love chocolate, I\'m a chocoholic. I love candy too, sweet, sugar candy';
    var myRegExp = /choc(olate|oholic)?|(sugar )?candy/gi;
    myString = myString.replace(myRegExp, 'salad');
    alert(myString);
</script>
</body>
</html>